package com.xiaoyang.forum.service.impl;

import com.xiaoyang.forum.common.code.Result;
import com.xiaoyang.forum.common.code.ResultCode;
import com.xiaoyang.forum.common.exception.ApplicationException;
import com.xiaoyang.forum.domain.pojo.Board;
import com.xiaoyang.forum.domain.vo.BoardVO;
import com.xiaoyang.forum.mapper.BoardMapper;
import com.xiaoyang.forum.service.IBoardService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: XiaoYang
 * @CreateTime: 2025-08-13
 * @Description: 版块实现类
 */
@Service
public class BoardServiceImpl extends ServiceImpl<BoardMapper, Board> implements IBoardService {

    @Autowired
    private BoardMapper boardMapper;

    @Override
    public List<BoardVO> selectByNum(Integer num) {
        if (num < 0) {
            throw new ApplicationException(Result.failed(ResultCode.FAILED_PARAMS_VALIDATE));
        }

       return boardMapper.selectByNum(num);
    }
}
